#include "Thread.h"

void SetThreadDetachAttr(pthread_attr_t* attr)
{
	    pthread_attr_t* pAttr = attr;
		int ret = 0;

	    ret = pthread_attr_init(pAttr);
	    if(ret != 0)
	    {
			 printf("pthread_attr_init error\n");
			 return;
		}

	    ret = pthread_attr_setdetachstate(pAttr, PTHREAD_CREATE_DETACHED);
	    if(ret != 0)
        {
	          printf("pthread_attr_setdetachstate error\n");
	          return;
        }
	    return;
}

void CreateThread(pthread_t *tid,void *(*func)(void *),void *arg)
{
	pthread_attr_t attr;
	SetThreadDetachAttr(&attr);
	pthread_create(tid, &attr, (void *)func, arg);
}



